package com.flower8.service.impl;

import com.flower8.dao.DataStatistDao;
import com.flower8.dto.ActiveAwardlogDto;
import com.flower8.service.DataStatistService;
import com.flower8.utils.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author: tanglin
 * @Date: 2019/09/26 17:09
 * @Version: 1.0
 */
@Service
public class DataStatistServiceImpl implements DataStatistService {

    @Autowired
    private DataStatistDao dataStatistDao;

    /**
     * 统计抢红包分布情况
     * @return
     * @throws Exception
     */
    @Override
    public List<Map> getRedPagData() throws Exception {
        return dataStatistDao.getRedPagData();
    }

    /**
     * 统计大转盘抽奖分布情况
     * @return
     * @throws Exception
     */
    @Override
    public List<Map> getBigWheelData() throws Exception {
        return dataStatistDao.getBigWheelData();
    }

    /**
     * 统计总数量
     * @return
     * @throws Exception
     */
    @Override
    public Map getDataTotal() throws Exception {
        return dataStatistDao.getDataTotal();
    }

    /**
     * 查询红包明细
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public List<ActiveAwardlogDto> getRedPagDetail(PageData pd) throws Exception {
        return dataStatistDao.getRedPagDetail(pd);
    }

    /**
     * 查询红包明细数量
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public int getRedPagDetailCount(PageData pd) throws Exception {
        return dataStatistDao.getRedPagDetailCount(pd);
    }

    /**
     * 查询红包明细总次数和总金额
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public Map getRedPagDetailTotal(PageData pd) throws Exception {
        return dataStatistDao.getRedPagDetailTotal(pd);
    }

    /**
     * 查询大转盘明细
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public List<ActiveAwardlogDto> getBigWheelDetail(PageData pd) throws Exception {
        return dataStatistDao.getBigWheelDetail(pd);
    }

    /**
     * 查询大转盘明细数量
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public int getBigWheelDetailCount(PageData pd) throws Exception {
        return dataStatistDao.getBigWheelDetailCount(pd);
    }

    /**
     * 查询大转盘明细总次数和总金额
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public Map getBigWheelDetailTotal(PageData pd) throws Exception {
        return dataStatistDao.getBigWheelDetailTotal(pd);
    }

    /**
     * 获取注册人数统计
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public List<Map> registerData(PageData pd) throws Exception {
        List<Map> res = dataStatistDao.registerData(pd);
        for(int i=0; i < res.size(); i++){
            Map resMap = res.get(i);
            resMap.put("y", res.get(i).get("count"));
        }
        return res;
    }

    /**
     * 查询发红包列表
     *
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public List<Map> getRedbagList(PageData pd) throws Exception {
        return dataStatistDao.getRedbagList(pd);
    }

    /**
     * 查询发红包列表数量
     *
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public int getRedbagListCount(PageData pd) throws Exception {
        return dataStatistDao.getRedbagListCount(pd);
    }

    /**
     * 获取发红包总金额
     *
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public Map getRedbagTotal(PageData pd) throws Exception {
        return dataStatistDao.getRedbagTotal(pd);
    }

}
